package com.tairan.chapter.activiti.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;

import java.util.TimeZone;

@Configuration
public class SpringMvcConfig {

//    @Bean
//    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
//        return builder.createXmlMapper(false).failOnEmptyBeans(true).build();
//    }

    @Bean
    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
        Jackson2ObjectMapperBuilder json = Jackson2ObjectMapperBuilder.json();
        json.timeZone(TimeZone.getDefault());
        json.simpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new MappingJackson2HttpMessageConverter(json.build());
    }
}
